using Microsoft.AspNetCore.Mvc;
using Process.Application.Services;
using Process.Domain.DTO.InputDTO;
using Process.Domain.DTO.OutDTO;
using Process.Domain.Entities;
using Process.Result;

namespace Process.Api.Controllers
{
    [ApiController]
    [Route("api/[controller]/[action]")]
    public class TicketModelController : ControllerBase
    {
        private readonly ITicketAppService<TicketModel> _service;
        public TicketModelController(ITicketAppService<TicketModel> service)
        {
            _service = service;
        }

        /// <summary>
        /// 添加工单
        /// </summary>
        /// <param name="dto">工单数据传输对象</param>
        /// <returns>API结果</returns>
        [HttpPost]
        public ApiResult<int> AddTicketModel(AddTicketDTO dto)
        {
            return _service.AddTicket(dto);
        }

        /// <summary>
        /// 分页查询工单
        /// </summary>
        /// <param name="input">分页及查询参数</param>
        /// <returns>分页工单数据</returns>
        [HttpGet]
        public Apipaging<PagingTicketDTO> ShowTicket([FromQuery] PagingTicketInput input)
        {
            return _service.PagingTicket(input);
        }

        /// <summary>
        /// 删除工单
        /// </summary>
        /// <param name="id">工单主键Id</param>
        /// <returns>API结果</returns>
        [HttpDelete]
        public ApiResult<int> DeleteTicketModel(long id)
        {
            return _service.DeleteTicket(id);
        }

        /// <summary>
        /// 修改工单
        /// </summary>
        /// <param name="input">工单更新数据</param>
        /// <returns>API结果</returns>
        [HttpPost]
        public ApiResult<int> UpdateTicketModel(UpdateTicketInput input)
        {
            return _service.UpdateTicket(input);
        }
    }
} 